import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

class Exception_handling_5{
  public static void main(String[] args) {
    try {
      checkFileNotEmpty("sample.txt");
      System.out.println("File is not empty.");
    } catch (FileNotFoundException e) {
      System.out.println("Error: " + e.getMessage());
    } catch (EmptyFileException e) {
      System.out.println("Error: " + e.getMessage());
    }
  }

  public static void checkFileNotEmpty(String fileName) throws FileNotFoundException, EmptyFileException {
    File file = new File(fileName);
    Scanner scanner = new Scanner(file);

    if (!scanner.hasNextLine()) {
      scanner.close();
      throw new EmptyFileException("File is empty or does not exist");
    }

    scanner.close();
  }
}

class EmptyFileException extends Exception {
  public EmptyFileException(String message) {
    super(message);
  }
}